ENV_ASIMUT	= MBK_CATAL_NAME=CATAL_ASIMUT

OBJECTIVES = translate boolean-optimization synthesis \
synthesis-optimization place route check-design-rules

all: $(OBJECTIVES)

translate: cemisidfft_chip.vhdl
	vasy -Vaop -H -P cemisidfft_pkgs cemisidfft_chip
	vasy -Vaop -H cell
	touch translate

simulate-behavioral: translate test_cemisidfft_chip.pat
	$(ENV_ASIMUT) asimut cemisidfft_chip test_cemisidfft_chip test_result
	touch simulate-behavioral

test_cemisidfft_chip.pat: test_cemisidfft_chip.c
	genpat test_cemisidfft_chip

boolean-optimization: translate
	boom -l 2 data_memory_model
	boom -l 2 tri_state
	boom -l 2 decoder_3
	boom -l 2 decoder_6
	boom -l 2 mux_64
	boom -l 2 and2_gate
	boom -l 2 alu_model
	boom -l 2 and_gate
	boom -l 2 banderas
	boom -l 2 celda_multiplicadora
	boom -l 2 cemisidfft_chip_model
	boom -l 2 comparation_unit
	boom -l 2 counter
	boom -l 2 decoder
	boom -l 2 dependency_selection
	boom -l 2 ffd
	boom -l 2 data_mem_control
	boom -l 2 fft_fsm
	boom -l 2 hazard_fsm
	boom -l 2 hazards_unit_model
	boom -l 2 index_unit
	boom -l 2 inst_memory
	boom -l 2 lu_model
	boom -l 2 mlu
	boom -l 2 multiplicador_encauzado_model
	boom -l 2 mux2to1
	boom -l 2 mux4to1
	boom -l 2 mux
	boom -l 2 not_gate
	boom -l 2 op_unit
	boom -l 2 pipeline_cu_alu_model
	boom -l 2 pipeline_instruction_model
	boom -l 2 pipem_model
	boom -l 2 reg12bits
	boom -l 2 reg_1bit
	boom -l 2 reg4bits
	boom -l 2 reg5bits
	boom -l 2 sumador
	boom -l 2 sum_encauzado_model
	boom -l 2 pc
#	boom -l 2 vector_register_file_model
	touch boolean-optimization

synthesis: boolean-optimization
	boog data_memory_model_o data_memory_model
#	boog vector_element_model_o vector_element_model
	boog tri_state_o tri_state
	boog decoder_3_o decoder_3
	boog decoder_6_o decoder_6
	boog mux_64_o mux_64
	boog and2_gate_o and2_gate
	boog alu_model_o alu_model
	boog and_gate_o and_gate
	boog banderas_o banderas
	boog celda_multiplicadora_o celda_multiplicadora
	boog cemisidfft_chip_model_o cemisidfft_chip_model
	boog comparation_unit_o comparation_unit
	boog counter_o counter
	boog decoder_o decoder
	boog dependency_selection_o dependency_selection
	boog ffd_o ffd
	boog data_mem_control_o data_mem_control
	boog fft_fsm_o fft_fsm
	boog hazard_fsm_o hazard_fsm
	boog hazards_unit_model_o hazards_unit_model
	boog index_unit_o index_unit
	boog inst_memory_o inst_memory
	boog lu_model_o lu_model
	boog mlu_o mlu
	boog multiplicador_encauzado_model_o multiplicador_encauzado_model
	boog mux2to1_o mux2to1
	boog mux4to1_o mux4to1
	boog mux_o mux
	boog not_gate_o not_gate
	boog op_unit_o op_unit
	boog pipeline_cu_alu_model_o pipeline_cu_alu_model
	boog pipeline_instruction_model_o pipeline_instruction_model
	boog pipem_model_o pipem_model
	boog reg12bits_o reg12bits
	boog reg_1bit_o reg_1bit
	boog reg4bits_o reg4bits
	boog reg5bits_o reg5bits
	boog sumador_o sumador
	boog sum_encauzado_model_o sum_encauzado_model
	boog pc_o pc
#	boog vector_register_file_model_o vector_register_file_model
	touch synthesis

synthesis-optimization: synthesis
	loon -o data_memory_model
#	loon -o vector_element_model
	loon -o tri_state
	loon -o decoder_3
	loon -o decoder_6
	loon -o mux_64
	loon -o and2_gate
	loon -o alu_model
	loon -o and_gate
	loon -o banderas
	loon -o celda_multiplicadora
	loon -o cemisidfft_chip_model
	loon -o comparation_unit
	loon -o counter
	loon -o decoder
	loon -o dependency_selection
	loon -o ffd
	loon -o data_mem_control
	loon -o fft_fsm
	loon -o hazard_fsm
	loon -o hazards_unit_model
	loon -o index_unit
	loon -o inst_memory
	loon -o lu_model
	loon -o mlu
	loon -o multiplicador_encauzado_model
	loon -o mux2to1
	loon -o mux4to1
	loon -o mux
	loon -o not_gate
	loon -o op_unit
	loon -o pipeline_cu_alu_model
	loon -o pipeline_instruction_model
	loon -o pipem_model
	loon -o reg12bits
	loon -o reg_1bit
	loon -o reg4bits
	loon -o reg5bits
	loon -o sumador
	loon -o sum_encauzado_model
	loon -o pc
#	loon -o vector_register_file_model
	touch synthesis-optimization

place-route: place route

place: synthesis-optimization
	ocp -ring cemisidfft_chip cemisidfft_chip
	touch place

route: place
	nero -V -6 -p cemisidfft_chip cemisidfft_chip cemisidfft_chip_nero
	touch route

check-design-rules: place route
	druc cemisidfft_chip_nero
	touch check-design-rules

clean:
	rm -rf *.vbe \
		*.vst \
		*.xsc \
		*.pat \
		*.ap \
		*.cif \
		*.drc \
		$(OBJECTIVES) \
		*~
